package com.fujica.invoicing.controller;

import com.fujica.invoicing.request.goods.GoodsDetailReq;
import com.fujica.invoicing.request.goods.GoodsListReq;
import com.fujica.invoicing.service.IGoodsService;
import com.fujica.invoicing.utils.Result;
import com.fujica.invoicing.utils.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName GoodsController
 * @Description TODO  商品
 * @Author admin
 * @Date 2020/8/15 10:51
 * @Version 1.0
 **/
@RestController
@RequestMapping("invoicing/goods")
@Api(tags = "商品")
public class GoodsController {

    @Autowired
    private IGoodsService iGoodsService;

    @GetMapping
    @ApiOperation("商品列表")
    @ResponseBody
    public Result list() {
        return iGoodsService.list();
    }

    @GetMapping("/detail/{storeId}/{goodsId}")
    @ApiOperation("单个商品的详细信息(销售价格等)")
    @ResponseBody
    public Result detail (@PathVariable("storeId") Integer storeId, @PathVariable("goodsId") Integer goodsId){

        if (goodsId != null && storeId != null) {
            return iGoodsService.detail(goodsId, storeId);
        }
        return ResultBody.badReq("传输数据有误");
    }
}
